<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@include file="/jsp/common/head.jsp"%>

<div class="right">
    <div class="location">
        <strong>你现在所在的位置是:</strong>
        <span>增加电子图书</span>
    </div>
    <div class="providerAdd">
        <form id="billForm" name="billForm" method="post" action="${pageContext.request.contextPath }/bill/add">
            <!--div的class 为error是验证错误，ok是验证成功-->
            <input type="hidden" name="method" value="add">
            <div>
                <label for="title">图书名称：</label>
                <input type="text" name="title" id="title" value="">
                <font color="red"></font>
            </div>
            <div>
                <label for="summary">图书摘要：</label>
                <input type="text" name="summary" id="summary" value="">
                <font color="red"></font>
            </div>
            <div>
                <label for="uploaduser">上传人：</label>
                <input type="text" name="uploaduser" id="uploaduser" value="">
                <font color="red"></font>
            </div>
            <div>
                <label for="createdate">上传时间：</label>
                <input type="text" name="createdate" id="createdate" value="">
                <font color="red"></font>yyyy-MM-dd
            </div>
            <div class="providerAddBtn">
                <input type="submit" name="add" id="add" value="保存">
                <input type="button" id="back" name="back" value="返回" >
            </div>
        </form>
    </div>
</div>
</section>
<%@include file="/jsp/common/foot.jsp" %>
<script>

    //页面加载的时候加载供应商信息
    $.ajax({
        url:"/provider/list",
        success:function (data) {
            //console.log(data);

            //创建一个字符串变量
            var optins = "";

            //遍历数组
            for(var i = 0 ; i < data.length ; i++){
                //把数组中的每一个元素的id和名称拼接到下拉项option标签中
                optins += "<option value='"+data[i].id+"'>"+data[i].proname+"</option>";
            }
            //把创建的所有的option标签添加到select表的后面
            $("#providerId").append(optins);
            $("#providerId").var(${bill.providerid})
        }
    })
</script>